/**
详情页
 */

import React,{ Component } from 'react';
import {
Text,
View,
ScrollView,
Image,
} from 'react-native'
import {styles}  from '../styles/listdetail';

import HeaderView from '../listdetail/headerview'
import HousingView from '../listdetail/housing'
import TitleView from '../listdetail/title'
import ConfigView from '../listdetail/config'
import TrafficView from '../listdetail/traffic'
import AroundView from '../listdetail/around'
import HouseMapView from '../listdetail/map'
import RecommendedView from '../listdetail/recommended'
import Swipers from '../components/Swipers'

export default class ListDetailScreen extends Component {
    constructor(props) {
        super(props);

    }

    state = {
        id: '',
        data:''
    };
    componentWillMount() {

            const {
                state: {
                    params: {
                        id
                        }
                    }
                } = this.props.navigation;
            this.setState({
                id: id,
            });

        this.getListDetail(id);
    }

    //请求列表详情
    getListDetail = (id) => {
        const {goBack} = this.props.navigation;
        // var a = {
        //     id: id
        // }
        // const jsonString = JSON.stringify(a);

        //const REQUEST_URL = Config.breedAppUrl + Config.getystlofac_url;
        // console.log(REQUEST_URL + '=====jsonString=====' + jsonString);
        fetch('http://121.40.178.164:4040/react-service/api/houseInfo/getDetail.do', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: 'id='+id
        }).then((response) => response.json()).then((responseJson) => {
            console.log(responseJson);

            const result=responseJson.res.data.record;
            if (responseJson.code == 0) {

            }

            this.setState({
                data:result,
            })
            //if (responseJson.code == 200) {
            //    this.dayOrder = responseJson.data.daage;
            //
            //} else if (responseJson.status == 401){
            //    alert('登录超时，请重新登录');
            //    //  goBack(null);
            //} else {
            //    alert(responseJson.message);
            //    goBack(null);
            //}

        }).catch((error) => {
            console.error(error);
        });
    }

    render() {
        return (
            <View style={styles.container}>

                <ScrollView
                    bounces={false}
                    showsVerticalScrollIndicator={false}
                    automaticallyAdjustContentInsets={false}
                    removeClippedSubviews={false}
                    style={styles.box}
                    contentContainerStyle={{alignItems: 'center', backgroundColor: '#fff', paddingBottom: 10}}
                >
                {/*<HeaderView />*/}
                    <Swipers />
                <HousingView housePrice={this.state.data.rentPrice} address={this.state.data.address}/>
                <TitleView/>
                <ConfigView />
                <TrafficView/>
                <AroundView/>
                <HouseMapView/>
                <RecommendedView/>
                </ScrollView>
            </View>
        );
    }

}



